import { postHttpParam } from "../../api";
import { createAsyncThunk } from "@reduxjs/toolkit";
import { encryptedData, publicKey } from "../../utils/encryptedData";

// 登录类型
interface LoginDataState {
  email: string;
  pwd: string;
}
// 登录
export const login = createAsyncThunk(
  "user/login",
  async (data: LoginDataState) => {
    data.pwd = encryptedData(publicKey, data.pwd) as string;
    const resp = await postHttpParam("/health/doctor/v1/login", data);
    return resp;
  }
);
